package cn.gdcp.myapplication3;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {
    private ListView nameListView;
    private ArrayList<Student> studentArrayList=new ArrayList<>();
    private MainAdapter adapter;
    private final String[] nameArr={"1","2","3","4","5","6"};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initStuList();


        nameListView=findViewById(R.id.name_listview);

        adapter=new MainAdapter(MainActivity.this,studentArrayList);
        nameListView.setAdapter(adapter);

    }

    private void initStuList() {
        Student s1=new Student(R.drawable.a,"一",11);
        Student s2=new Student(R.drawable.as1,"二",12);
        Student s3=new Student(R.drawable.as2,"三",13);
        Student s4=new Student(R.drawable.as3,"四",14);
        Student s5=new Student(R.drawable.as4,"五",15);

        studentArrayList.add(s1);
        studentArrayList.add(s2);
        studentArrayList.add(s3);
        studentArrayList.add(s4);
        studentArrayList.add(s5);
    }
}
